package cn.edu.xmu.oomall.customer.model.bo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotNull;
import java.util.HashMap;
import java.util.Map;

/**
 * @author: zhang yu
 * @date: 2021/12/8 17:31
 * @version: 1.0
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Customer {
    /*顾客状态*/
    public enum State {
        NORAML((byte)0, "正常"),
        FORBIDDEN((byte)1, "被封禁");
        private static final Map<Byte, State> typeMap;

        static { //由类加载机制，静态块初始加载对应的枚举属性到map中，而不用每次取属性时，遍历一次所有枚举值
            typeMap = new HashMap();
            for (State enum1 : values()) {
                typeMap.put(enum1.code, enum1);
            }
        }

        private Byte code;
        private String description;

        State(Byte code, String description) {
            this.code = code;
            this.description = description;
        }

        public static State getTypeByCode(Byte code) {
            return typeMap.get(code);
        }

        public Byte getCode() {
            return code;
        }

        public String getDescription() {
            return description;
        }

    }
    private Long id;

    private String mobile;

    private String email;

    private String userName;

    private String password;

    private String name;

    private Byte state;

    private Long point;

    private Long creatorId;
    private String creatorName;
    private Long modifierId;
    private String modifierName;
}
